package com.alarm.app.receiver;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;


public class DfReceiver /*extends BroadcastReceiver */{
	
//	public static final String ACTION_RESTART_SERVICE = "com.youyuan.yyhl.dfreceiver.restart";
//	public static final String ACTION_RESTART_SERVICE_START_FORK = "com.youyuan.yyhl.start.fork";
//
//	private static final int RESTART_SERVICE_TIME = 50000;
//
//	private static final int FORK_LOOP_INTERVAL_TIME = 60;//单位秒
//
//	private AlarmManager alarmManager;
//
//    @Override
//    public void onReceive(Context context, Intent intent) {
//    	if (intent == null) {
//    	    return;
//    	}
//
//    	final String action = intent.getAction();
//
//		if (ACTION_RESTART_SERVICE.equals(action)){
//
//			alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
//
//			intent.setClass(context, ScreenListenerServer.class);
//			PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0);
//            alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + RESTART_SERVICE_TIME, pendingIntent);
//
//			intent.setClass(context, DfService.class);
//			pendingIntent = PendingIntent.getService(context, 0, intent, 0);
//			alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + RESTART_SERVICE_TIME, pendingIntent);
//
//		} else if (ACTION_RESTART_SERVICE_START_FORK.equals(action)) {// 启动fork进程
////			if (LogUtils.DEBUG) {
////				LogUtils.e(AlarmReceiver.LOOP_TAG, "启动fork进程");
////				FileUtils.writeFileSdcard("启动fork进程");
////			}
//			Intent startIntent = new Intent(ACTION_RESTART_SERVICE);
//			context.sendBroadcast(startIntent);
//			// 启动fork进程
//			NativeDaemonRuntime.getInstance().startForkService(context.getPackageName() , "/com.app.service.DfService",":df_service_v1",FORK_LOOP_INTERVAL_TIME);
//		} else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {// 开机
////			if (LogUtils.DEBUG) {
////				LogUtils.e(AlarmReceiver.LOOP_TAG, "机器重启");
////				FileUtils.writeFileSdcard("机器重启");
////			}
//			// 启动fork进程
//			NativeDaemonRuntime.getInstance().startForkService(context.getPackageName() , "/com.app.service.DfService",":df_service_v1",FORK_LOOP_INTERVAL_TIME);
//		} else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) {// 应用卸载
//
////			if (LogUtils.DEBUG) {
////				LogUtils.e(AlarmReceiver.LOOP_TAG, "应用卸载:" + intent.getDataString() + "=" + context.getPackageName());
////				FileUtils.writeFileSdcard("应用卸载:" + intent.getDataString() + "=" + context.getPackageName());
////			}
//
//			if(("package:"+context.getPackageName()).equals(intent.getDataString())){
//				// 关闭通知轮询
//	            AlarmReceiver.stopNotificationAlarm();
//				// 停止fork进程
//				NativeDaemonRuntime.getInstance().stopProcess(context.getPackageName(),":df_service_v1");
//			}
//		}
//    }
//
}
